second derivative using implicit differentiation